﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using TopCoder.Util.Calendar.Entry;

namespace Studentium.Entities
{
    public enum AttendenceStatus
    {
        Registered = 0, Attended, WishList
    }
    public class ClassAttendance 
    {
        private int id;        
        private CalendarEntry calendarEntry;
        private Student student;
        private string comment;
        private AttendenceStatus status = AttendenceStatus.Registered;
        
        [Browsable(false)]
        public virtual int Id
        {
            get { return id; }
            set { id = value; }
        }

        public virtual AttendenceStatus Status
        {
            get { return status; }
            set { status = value; }
        }

        // purely visual field
        public virtual DateTime Date
        {
            get
            {
                if (calendarEntry == null)
                    return DateTime.Now;
                return calendarEntry.Date;
            }                        
        }

        [Browsable(false)]
        public virtual CalendarEntry CalendarEntry
        {
            get
            {
                return calendarEntry;
            }
            set
            {                
                calendarEntry = value;
            }
        }

        // purely visual field
        [DisplayName("Class name")]
        public virtual string FullClassName
        {
            get
            {
                if (calendarEntry == null)
                    return "";
                return calendarEntry.FullName;
            }            
        }

        [Browsable(false)]
        public virtual Student Student
        {
            get { return student; }
            set { student = value; }
        }

        public virtual string Comment
        {
            get { return comment; }
            set { comment = value; }
        }

        public ClassAttendance()
        {
        }

        public ClassAttendance(Student student)
        {
            this.student = student;
        }

        public override int GetHashCode()
        {
            return id;
        }

        public override bool Equals(object obj)
        {
            if (obj == null || !(obj is ClassAttendance))
                return false;

            return ((ClassAttendance) obj).Id == id;
        }
    }
}
